package com.ruoyi.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.admin.domain.ZhxBook;
import com.ruoyi.admin.service.IZhxBookService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作品管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-11
 */
@RestController
@RequestMapping("/ZhxAdmin/ZhxBook")
public class ZhxBookController extends BaseController
{
    @Autowired
    private IZhxBookService zhxBookService;

    /**
     * 查询作品管理列表
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxBook:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhxBook zhxBook)
    {
        startPage();
        List<ZhxBook> list = zhxBookService.selectZhxBookList(zhxBook);
        return getDataTable(list);
    }

    /**
     * 导出作品管理列表
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxBook:export')")
    @Log(title = "作品管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZhxBook zhxBook)
    {
        List<ZhxBook> list = zhxBookService.selectZhxBookList(zhxBook);
        ExcelUtil<ZhxBook> util = new ExcelUtil<ZhxBook>(ZhxBook.class);
        util.exportExcel(response, list, "作品管理数据");
    }

    /**
     * 获取作品管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxBook:query')")
    @GetMapping(value = "/{bookId}")
    public AjaxResult getInfo(@PathVariable("bookId") Long bookId)
    {
        return success(zhxBookService.selectZhxBookByBookId(bookId));
    }

    /**
     * 新增作品管理
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxBook:add')")
    @Log(title = "作品管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhxBook zhxBook)
    {
        return toAjax(zhxBookService.insertZhxBook(zhxBook));
    }

    /**
     * 修改作品管理
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxBook:edit')")
    @Log(title = "作品管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhxBook zhxBook)
    {
        return toAjax(zhxBookService.updateZhxBook(zhxBook));
    }

    /**
     * 删除作品管理
     */
    @PreAuthorize("@ss.hasPermi('ZhxAdmin:ZhxBook:remove')")
    @Log(title = "作品管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bookIds}")
    public AjaxResult remove(@PathVariable Long[] bookIds)
    {
        return toAjax(zhxBookService.deleteZhxBookByBookIds(bookIds));
    }

    /**
     * 通过图书
     */

}
